﻿namespace PrimeNumbers
{
    internal class Program
    {
        static void Main(string[] args)
        {
        start:
            Console.WriteLine("请您输入一个数");
            string s = Console.ReadLine();
            for (int i = 0; i < s.Length; i++)
            {
                if (!(s[i] >= '0' && s[i] <= '9'))
                {
                    Console.WriteLine("格式不对，请重新输入！！！");
                    goto start;
                }
            }


            int a = Convert.ToInt32(s);
            int n;
            int count = 0;
            for (n = 2; n <= a; n++)
            {
                int i;
                for (i = 2; i < n; i++)
                {
                    if (n % i == 0)
                        break;
                }
                if (i == n)

                    count++;
            }
            Console.WriteLine("有{0}个质数", count);
            goto start;
        }
    }
}